package com.yuefresh.dish;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yuefresh.core.EntityManager;


@Service
@Transactional
public class DishManager extends EntityManager<Dish, Long> {
	
	/**
	 * 根据菜单获取菜品
	 * @param menu
	 */
	public List<Dish> getDishes(Menu menu) {
		List<Dish> dishes = this.find("select md.dish from MenuDish md where md.menu = ? and md.dish.isValid = 1", menu);
		return dishes;
	}
	
	/**
	 * 根据菜单及菜品获取菜品
	 * @param mid menu id
	 */
	public List<Dish> getDishes(Menu menu, DishType type) {
		List<Dish> dishes = this.find("select md.dish from MenuDish md where md.menu = ? and md.dish.type = ? and md.dish.isValid = 1", menu, type);
		return dishes;
	}
	
}
